package com.example.designpattern.strategy;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * @author long
 * @date 2024/11/12 13:20
 */
public enum StudyLanguageEnum {

    CHINESE("chinese","语文",Constants.StudyLanguage.CHINESE),

    MATHS("maths","数学",Constants.StudyLanguage.MATHS),

    ENGLISH("english","英语",Constants.StudyLanguage.ENGLISH);

    private String code;

    private String desc;

    private String beanName;

    StudyLanguageEnum(String code, String desc,String beanName){
        this.code = code;
        this.desc = desc;
        this.beanName = beanName;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getBeanName() {
        return beanName;
    }

    /**
     * 根据code查询枚举值对象
     * @param code
     * @return
     */
    public static StudyLanguageEnum of(String code){
        return Stream.of(values()).filter(e-> Objects.equals(e.getCode(),code))
                .findFirst().orElse(null);
    }
}
